//
//  MenuViewController.m
//  Leisure
//
//  Created by xalo on 16/6/28.
//  Copyright © 2016年 蓝鸥科技有限公司西安分公司. All rights reserved.
//

#import "MenuViewController.h"

@interface MenuViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)UIVisualEffectView *blurEffectView;
@property (nonatomic,strong)UIImageView *backImageView;

@end

@implementation MenuViewController
-(UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
        _tableView.contentInset = UIEdgeInsetsMake(200, 0, 0, 0);
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.backgroundColor = [UIColor clearColor];
    }
    return _tableView;
}

-(UIVisualEffectView *)blurEffectView{
    if (!_blurEffectView) {
        _blurEffectView = [[UIVisualEffectView alloc]initWithFrame:self.tableView.frame];
    }
    return _blurEffectView;
}
-(UIImageView *)backImageView{
    if (!_backImageView) {
        _backImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"1019359089.jpg"]];
        [_backImageView setFrame:self.tableView.frame];
    }
    return _backImageView;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.translucent = NO;
    self.blurEffectView.effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    self.blurEffectView.alpha = 0.5;

    [self.view addSubview:self.tableView];
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"menu_cell"];
    [self.view insertSubview:self.backImageView atIndex:0];
    [self.view insertSubview:self.blurEffectView atIndex:1];
    

}




-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"menu_cell" forIndexPath:indexPath];
    cell.textLabel.text = self.titleArray[indexPath.row];
    cell.textLabel.highlightedTextColor = [UIColor grayColor];
    
    
    
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor clearColor];
    cell.selectedBackgroundView = view;
    cell.backgroundColor = [UIColor clearColor];

    
    return cell;
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.vcArray.count;
}

//点击cell的时候响应代理事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    RightViewController * rightVC = self.vcArray[indexPath.row];
    rightVC.isSlider = NO;//设置抽屉状态为关闭
    if ([self.delegate respondsToSelector:@selector(menuViewControllerDidClickCellWithVC:)]) {
        [self.delegate menuViewControllerDidClickCellWithVC:rightVC];
    }
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

@end
